import java.util.Random;
import java.util.Scanner;

public class Test {

    public static boolean isPrimeNumber(int num){

        if(num == 1){
            return false;
        }

        for(int i = 2; i <= Math.sqrt(num); i++){
            if(num % i == 0){
                return false;
            }
        }
        return true;
    }

    public static void findNarcissisticNum(){
        // 找出水仙花数
        for(int i = 0; i < 999; i++){
            int count = 0;
            int tmp = 0;
            int sum = 0;
            tmp = i;
            while(tmp != 0){
                tmp /= 10;
                count++;
            }

            tmp = i;
            while(tmp != 0){
                sum += Math.pow((tmp % 10), count);
                tmp /= 10;
            }

            if(sum == i){
                System.out.println(i);
            }
        }
    }

    public static void print(){
        Scanner in = new Scanner(System.in);

        /*System.out.println("请输入您的年龄:");
        int age = in.nextInt();

        in.nextLine();

        System.out.println("请输入您的姓名:");
        String name = in.nextLine();

        System.out.println("请输入您的工资:");
        double money = in.nextDouble();

        System.out.println("您的信息:");
        System.out.println("姓名:" + name + " 年龄:" + age + " 工资:" + money);*/

        int sum = 0;
        while(in.hasNextInt()){ // 读取多个int,进行累加
            int data = in.nextInt();

            sum += data;
        }
        System.out.println(sum);

        in.close();
    }

    public static void guessNum(){
        Scanner in = new Scanner(System.in);
        Random rand = new Random();

        int guessN = rand.nextInt(100); // [0, 100)
        while(true){
            System.out.println("请输入要猜测的数字:");
            int num = in.nextInt();

            if(num > guessN){
                System.out.println("猜大了！");
            }else if(num < guessN){
                System.out.println("猜小了！");
            }else {
                System.out.println("恭喜你,猜中了！");
                break;
            }
        }

        in.close();
    }

    public static int add(int x, int y){
        return x + y;
    }

    public static void swap(int x, int y){
        int tmp = x;
        x = y;
        y = tmp;
    }

    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println("交换前: a = " + a + ", b = " + b);
        swap(a, b);
        System.out.println("交换后: a = " + a + ", b = " + b);
    }
    public static void main1(String[] args) {
        /*int num  = 17;
        boolean flag = isPrimeNumber(num);
        System.out.println(num + "是素数吗?");
        System.out.println(flag);*/

        // findNarcissisticNum();
        // print();

        /*int a = 10;
        int b = 20;
        int ret = add(10, 20);
        System.out.println(ret);*/

    }
}

